package de.hauschild.orbitvm.vm.instruction.impl.single;

import de.hauschild.orbitvm.vm.VM;
import de.hauschild.orbitvm.vm.instruction.impl.AbstractInstruction;

public class Input extends AbstractInstruction {

  private final int argumentAdress;

  public Input(final int theInstructionCounter, final int theArgumentAdress) {
    super(theInstructionCounter);
    argumentAdress = theArgumentAdress;
  }

  @Override
  public void evaluate(final VM vm) {
    vm.getMemory()[getInstructionCounter()] = vm.getInput()[argumentAdress];
  }

  @Override
  public String toString() {
    return String.format("%d: Input (%d)", getInstructionCounter(), argumentAdress);
  }

}
